package cn.spring.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.spring.bean.Shoppingcart;
import cn.spring.bean.Today;



public interface ShoppingcartMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Shoppingcart record);

    int insertSelective(Shoppingcart record);

    Shoppingcart selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Shoppingcart record);

    int updateByPrimaryKey(Shoppingcart record);
    
    List<Map<String, Object>> selectIsGou(int empId);
    
    int updateIsGou(int empId,int ordId);
    
    List<Map<String, Object>> selectByState(int empId,int ordId);
    
    List<Map<String, Object>> selectByState1(int ordId);
    
    int updateIsGouByOrdId(Integer empId,Integer ordId);
    
    List<Today> toDay();
    
    Double getTotal(String startTime,String endTime);
    
    List<Map<String, Object>> toDayCommodity();
    
    List<Map<String, Object>> toDayCommodityByWord(String word);
    
    @Select("select e.`name` as name,a.address as address,o.time,a.phone as phone,(select sum(s.total) from shoppingcart as s WHERE s.ord_id=o.id)as total,o.id as ordid,o.state as state from employee as e,address as a,orders as o where e.id=a.emp_id and e.id=o.emp_id and o.address_id=a.id and to_days(o.ordertime) = to_days(now()) and o.state not in (1,3) and e.`name`LIKE CONCAT(CONCAT('%',#{word}),'%') ORDER BY o.ordertime desc")
    List<Today> toDayByKey(@Param("word")String word);
    
    @Select("select SUM(s.total) from employee as e,shoppingcart as s,orders as o where  e.id=o.emp_id and s.ord_id=o.id  and o.state not in (1,3) and o.ordertime >=#{startTime} and o.ordertime <=#{endTime} and e.`name`LIKE #{word}")
    Double getTotalByKey(@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("word")String word);
    
    int deleteByOrdId(int id);
    
    List<Map<String, Object>> findAccounts();
    List<Map<String, Object>> finGoodsByOId(int oid);
}